import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {CartItem} from "@/views/Goods/components/api";

/**
 * 查询购物车列表
 * @param query
 * @returns {*}
 */

// export const getCartList = (query?: OrderListInfo): AxiosPromise<OrderItem[]> => {
//   return request({
//     url: '/wms/order/lineList',
//     params: query,
//     method: 'get'
//   });
// };

/**
 * 查询购物车列表
 * @param query
 * @returns {*}
 */
export const getCartList = (query?: OrderListInfo): AxiosPromise<OrderItem[]> => {
  return request({
    url: '/wms/order/list',
    params: query,
    method: 'get'
  });
};

// 订单列表总信息
export interface OrderListInfo extends PageQuery {
  status: number;
  items: OrderItemList;
}
// 订单列表
export type OrderItemList = OrderItem[];
// 订单项
export interface OrderItem {
  id: string;
  name: string;
  typeId: number;
  createTime: string;
  orderState: number;
  payLatestTime: string;
  postFee: number;
  payMoney: number;
  totalMoney: number;
  totalNum: number;
  skus: Sku[];
  payChannel: number;
  countdown: number;
  line: CartItem[];
}
export interface Sku {
  id: string;
  spuId: string;
  name: string;
  quantity: number;
  image: string;
  realPay: number;
  curPrice: number;
  // totalMoney?: any;
  properties: Property[];
  attrsText: string;
}
export interface Property {
  propertyMainName: string;
  propertyValueName: string;
}
// 订单状态
export const orderStatus = [
  { name: 'all', label: '全部订单' },
  { name: 'unpay', label: '待付款' },
  { name: 'deliver', label: '待发货' },
  { name: 'receive', label: '待收货' },
  { name: 'comment', label: '待评价' },
  { name: 'complete', label: '已完成' },
  { name: 'cancel', label: '已取消' }
];
